package com.example.baidulist;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.Nullable;

public class MainActvitiy extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if(!isTaskRoot()){
            finish();
            return;
        }

        setContentView(R.layout.main);
        Button btn = findViewById(R.id.button);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();

                int min = 1;
                int max = 100;
                int randomNum = (int)(Math.random() * (max - min + 1)) + min;

                Intent intent = new Intent(MainActvitiy.this, AppActivity.class);
                intent.putExtra("token",String.format("%d",randomNum));
                startActivity(intent);
            }
        });
    }
}
